{% extends 'base.html.twig' %}

{% block body %}

    {% for flash_message in app.session.flashbag.get('notice') %}
    <div class="alert alert-success">{{ flash_message }}</div>
    {% endfor %}

    {% for flash_message in app.session.flashbag.get('error') %}
        <div class="alert alert-danger">{{ flash_message }}</div>
    {% endfor %}

    <h2 class="page-header">Latest Todos</h2>

    <div class="group">
        <a href="/todo/create" class="btn btn-primary">create</a>
    </div>

    <table class="table table-striped">
    <thead>
        <tr>
            <th>#</th>
            <th>Todo</th>
            <th>Due date</th>
            <th>Operation</th>
        </tr>
    </thead>
    <tbody>
    {% for todo in todos %}
        <tr>
            <td>{{ todo.id }}</td>
            <td>{{ todo.name }}</td>
            <td>{{ todo.dueDate | date('Y-m-d') }}</td>
            <td>
                <a href="/todo/edit/{{ todo.id }}">edit</a>
                <a href="/todo/details/{{ todo.id }}">details</a>
                <a href="/todo/delete/{{ todo.id }}">delete</a>
            </td>
        </tr>
    {% endfor %}
    </tbody>
</table>
{% endblock %}